/*
 * AttributeExpansionDialog2.java
 *
 * Created on August 5, 2008, 3:17 PM
 */

import java.awt.Dimension;
import javax.swing.JList;
import javax.swing.table.DefaultTableModel;
import java.util.HashSet;
import java.util.HashMap;

/**
 *
 * @author  emre
 */
public class AttributeExpansionDialog2 extends javax.swing.JDialog {

    private BianaDatabase biana_database = null;
    private HashSet<String> expansionRelationTypesSet = null;
    // keys are list of (anded) attributes (to be ored) where list contains maps with keys  
    // of indivudual attributes and values are corresponding parameters like 
    // { "attribute1, attribute2": { "attribute1": { "parameter1": "value"} } }
    private HashMap<String, HashMap<String, HashMap<String, String>>> expansionAttributesMap = null;
    private Dimension initialSize = null;
    
    /** Creates new form AttributeExpansionDialog2 */
    public AttributeExpansionDialog2(java.awt.Container parent, BianaDatabase bDB, HashSet<String> pExpansionRelationTypesSet, HashMap<String, HashMap<String, HashMap<String, String>>> pExpansionAttributesMap) {    
        super();
        this.biana_database = bDB;
	this.expansionRelationTypesSet = pExpansionRelationTypesSet;
	this.expansionAttributesMap = pExpansionAttributesMap;
        this.setLocationRelativeTo(parent);
        initComponents();
    }
        
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jLabel1 = new javax.swing.JLabel();
        jScrollPane1 = new javax.swing.JScrollPane();
        jListRelation = new javax.swing.JList(ExternalDatabase.getAlleErTypes(this.biana_database.getAvailableExternalDatabases()));
        jLabel2 = new javax.swing.JLabel();
        jPanelAdditional = new javax.swing.JPanel();
        jPanelAdditional.setVisible(false);
        jLabel5 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jLabel7 = new javax.swing.JLabel();
        jTextFieldSimilarity = new javax.swing.JTextField();
        jTextFieldIdentity = new javax.swing.JTextField();
        jTextFieldCoverageMatch = new javax.swing.JTextField();
        jLabel6 = new javax.swing.JLabel();
        jTextFieldCoverageQuery = new javax.swing.JTextField();
        jTextFieldBitScore = new javax.swing.JTextField();
        jLabel8 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jLabel3.setVisible(false);
        jPanel1 = new javax.swing.JPanel();
        jScrollPane3 = new javax.swing.JScrollPane();
        jTableAttribute = new javax.swing.JTable();
        jButtonAttribute = new javax.swing.JButton();
        jScrollPane2 = new javax.swing.JScrollPane();
        jListAttribute = new JList(ExternalDatabase.getAllAttributes("eE",this.biana_database.getAvailableExternalDatabases()));
        jPanel2 = new javax.swing.JPanel();
        jButtonReset = new javax.swing.JButton();
        jButtonCancel = new javax.swing.JButton();
        jButtonAccept = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("Predict Relations");
        setModal(true);
        setResizable(false);

        jLabel1.setText("1. Select relation type to expand:");

        jListRelation.addListSelectionListener(new javax.swing.event.ListSelectionListener() {
            public void valueChanged(javax.swing.event.ListSelectionEvent evt) {
                jListRelationValueChanged(evt);
            }
        });
        jScrollPane1.setViewportView(jListRelation);

        jLabel2.setText("2. Select attributes to be used in expansion:");

        jPanelAdditional.setEnabled(false);

        jLabel5.setText("Identity (%):");

        jLabel4.setText("Bit score:");

        jLabel7.setText("Query coverage (%):");

        jTextFieldSimilarity.setName("similarity"); // NOI18N

        jTextFieldIdentity.setName("identities"); // NOI18N

        jTextFieldCoverageMatch.setName("coverage_B"); // NOI18N

        jLabel6.setText("Similarity (%):");

        jTextFieldCoverageQuery.setName("coverage_A"); // NOI18N

        jTextFieldBitScore.setName("bit_score"); // NOI18N

        jLabel8.setText("Match coverage (%):");

        org.jdesktop.layout.GroupLayout jPanelAdditionalLayout = new org.jdesktop.layout.GroupLayout(jPanelAdditional);
        jPanelAdditional.setLayout(jPanelAdditionalLayout);
        jPanelAdditionalLayout.setHorizontalGroup(
            jPanelAdditionalLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(org.jdesktop.layout.GroupLayout.TRAILING, jPanelAdditionalLayout.createSequentialGroup()
                .addContainerGap(24, Short.MAX_VALUE)
                .add(jLabel4)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(jTextFieldBitScore, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 29, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .add(11, 11, 11)
                .add(jPanelAdditionalLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
                    .add(org.jdesktop.layout.GroupLayout.LEADING, jPanelAdditionalLayout.createSequentialGroup()
                        .add(11, 11, 11)
                        .add(jLabel5))
                    .add(jLabel6))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(jPanelAdditionalLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING, false)
                    .add(jTextFieldIdentity, 0, 0, Short.MAX_VALUE)
                    .add(jTextFieldSimilarity, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 27, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .add(16, 16, 16)
                .add(jPanelAdditionalLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING, false)
                    .add(jPanelAdditionalLayout.createSequentialGroup()
                        .add(jLabel7)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(jTextFieldCoverageQuery, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 27, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                    .add(jPanelAdditionalLayout.createSequentialGroup()
                        .add(jLabel8)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(jTextFieldCoverageMatch, 0, 0, Short.MAX_VALUE)))
                .addContainerGap())
        );
        jPanelAdditionalLayout.setVerticalGroup(
            jPanelAdditionalLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanelAdditionalLayout.createSequentialGroup()
                .addContainerGap()
                .add(jPanelAdditionalLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(jPanelAdditionalLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
                        .add(jPanelAdditionalLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                            .add(jLabel4)
                            .add(jTextFieldBitScore, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                        .add(jTextFieldCoverageQuery, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                    .add(jPanelAdditionalLayout.createSequentialGroup()
                        .add(jPanelAdditionalLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                            .add(jLabel5)
                            .add(jLabel7)
                            .add(jTextFieldIdentity, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(jPanelAdditionalLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                            .add(jLabel6)
                            .add(jTextFieldSimilarity, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                            .add(jLabel8)
                            .add(jTextFieldCoverageMatch, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))))
                .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jLabel3.setText("3.(Optional) Adjust attribute parameters:");

        jTableAttribute.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "Attribute"
            }
        ) {
            boolean[] canEdit = new boolean [] {
                false
            };

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        jScrollPane3.setViewportView(jTableAttribute);
        jTableAttribute.getColumnModel().getColumn(0).setResizable(false);

        jButtonAttribute.setText("Add Attribute ->");
        jButtonAttribute.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonAttributeActionPerformed(evt);
            }
        });

        jListAttribute.addListSelectionListener(new javax.swing.event.ListSelectionListener() {
            public void valueChanged(javax.swing.event.ListSelectionEvent evt) {
                jListAttributeValueChanged(evt);
            }
        });
        jScrollPane2.setViewportView(jListAttribute);

        org.jdesktop.layout.GroupLayout jPanel1Layout = new org.jdesktop.layout.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(org.jdesktop.layout.GroupLayout.TRAILING, jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .add(jScrollPane2, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 108, Short.MAX_VALUE)
                .add(12, 12, 12)
                .add(jButtonAttribute, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 141, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
                .add(jScrollPane3, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 154, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanel1Layout.createSequentialGroup()
                .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(jPanel1Layout.createSequentialGroup()
                        .add(55, 55, 55)
                        .add(jButtonAttribute))
                    .add(jPanel1Layout.createSequentialGroup()
                        .addContainerGap()
                        .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                            .add(jScrollPane3, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 111, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                            .add(jScrollPane2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 111, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))))
                .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jButtonReset.setText("Reset");
        jButtonReset.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonResetActionPerformed(evt);
            }
        });

        jButtonCancel.setText("Cancel");
        jButtonCancel.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonCancelActionPerformed(evt);
            }
        });

        jButtonAccept.setText("Accept");
        jButtonAccept.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonAcceptActionPerformed(evt);
            }
        });

        org.jdesktop.layout.GroupLayout jPanel2Layout = new org.jdesktop.layout.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .add(jButtonAccept, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 75, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(jButtonReset, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 68, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(jButtonCancel)
                .addContainerGap(20, Short.MAX_VALUE))
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .add(jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(jButtonAccept)
                    .add(jButtonReset)
                    .add(jButtonCancel))
                .addContainerGap())
        );

        org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(layout.createSequentialGroup()
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(layout.createSequentialGroup()
                        .addContainerGap()
                        .add(jLabel1))
                    .add(layout.createSequentialGroup()
                        .addContainerGap()
                        .add(jLabel2))
                    .add(layout.createSequentialGroup()
                        .addContainerGap()
                        .add(jLabel3))
                    .add(layout.createSequentialGroup()
                        .add(155, 155, 155)
                        .add(jScrollPane1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 119, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                    .add(layout.createSequentialGroup()
                        .addContainerGap()
                        .add(jPanel1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(15, Short.MAX_VALUE))
            .add(layout.createSequentialGroup()
                .addContainerGap()
                .add(jPanelAdditional, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
	    //javi added
	    .add(layout.createSequentialGroup()
		 .addContainerGap()
		 .add(this.getJScopAdditionalPanel(), org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
		 .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
            .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()
                .addContainerGap(192, Short.MAX_VALUE)
                .add(jPanel2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(layout.createSequentialGroup()
                .addContainerGap()
                .add(jLabel1)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
                .add(jScrollPane1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 82, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .add(12, 12, 12)
                .add(jLabel2)
                .add(2, 2, 2)
                .add(jPanel1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(jLabel3)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(jPanelAdditional, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
		 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
		 .add(this.getJScopAdditionalPanel(), org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .add(jPanel2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

private void jButtonAttributeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonAttributeActionPerformed
    if( this.jListAttribute.getSelectedIndex() == -1 ){
        javax.swing.JOptionPane.showMessageDialog(this,
	"You must select at least one relation type and one attribute expansion",
	"BIANA ERROR",
	javax.swing.JOptionPane.ERROR_MESSAGE);
	return;
    }
    HashMap<String, HashMap<String, String>> attributeMap = new HashMap<String, HashMap<String, String>>();
    for(Object obj : this.jListAttribute.getSelectedValues()) {
        HashMap<String, String> parameterMap = new HashMap<String, String>();
        String attribute = obj.toString();
        if(attribute.equals("proteinsequence") && jListAttribute.getModel().getElementAt(jListAttribute.getLeadSelectionIndex()).equals("proteinsequence")) {
            if(isFloat(jTextFieldBitScore.getText())) {
                parameterMap.put(jTextFieldBitScore.getName(), jTextFieldBitScore.getText());
            }
            if(isFloat(jTextFieldCoverageMatch.getText())) {
                parameterMap.put(jTextFieldCoverageMatch.getName(), jTextFieldCoverageMatch.getText());
            }
            if(isFloat(jTextFieldCoverageQuery.getText())) {
                parameterMap.put(jTextFieldCoverageQuery.getName(), jTextFieldCoverageQuery.getText());
            }
            if(isFloat(jTextFieldIdentity.getText())) {
                parameterMap.put(jTextFieldIdentity.getName(), jTextFieldIdentity.getText());
            }
            if(isFloat(jTextFieldSimilarity.getText())) {
                parameterMap.put(jTextFieldSimilarity.getName(), jTextFieldSimilarity.getText());
            }
	    // If no paramter is specified for sequence similarity assume full identity
	    if (parameterMap.size() == 0) {
                parameterMap.put(jTextFieldCoverageMatch.getName(), "100");
                parameterMap.put(jTextFieldCoverageQuery.getName(), "100");
                parameterMap.put(jTextFieldIdentity.getName(), "100");
                parameterMap.put(jTextFieldSimilarity.getName(), "100");
	    }
        }
	// For now just adding proteinSequence -- to generalize need to fill HashMap<attr, HashMap<par, val>> dictionary for every attribute
	// passing over all selected attributes in the list
        attributeMap.put(attribute, parameterMap);
    }
    this.expansionAttributesMap.put("\""+Utilities.join(this.jListAttribute.getSelectedValues(),"\",\"")+"\"", attributeMap);
    //System.out.println(this.expansionAttributesMap.toString());
    String attr_str = Utilities.join(this.jListAttribute.getSelectedValues(),",");
    ((javax.swing.table.DefaultTableModel)this.jTableAttribute.getModel()).addRow(new Object[]{attr_str.toString()});
}//GEN-LAST:event_jButtonAttributeActionPerformed


    private javax.swing.JPanel getJScopAdditionalPanel(){
	
	if( this.jScopAdditionalPanel == null ){
	    this.jScopAdditionalPanel = new javax.swing.JPanel();
	    this.jScopAdditionalPanel.setLayout( new java.awt.FlowLayout() );
	    this.jScopAdditionalPanel.add( new javax.swing.JLabel("Select which category to expand:") );
	    
	    javax.swing.JScrollPane jScopCategoryScrollPane = new javax.swing.JScrollPane();
	    String[] scopCategories = {"Class", "Fold", "Superfamily", "Family", "Domain"};
	    javax.swing.JList jScopCategoryList = new javax.swing.JList(scopCategories);
	    jScopCategoryList.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
	    jScopCategoryScrollPane.setViewportView( jScopCategoryList );
	    jScopCategoryScrollPane.setVerticalScrollBarPolicy( javax.swing.JScrollPane.VERTICAL_SCROLLBAR_ALWAYS );
	    jScopCategoryScrollPane.setPreferredSize(new Dimension(150,50));

	    this.jScopAdditionalPanel.add( jScopCategoryScrollPane );
	    
	    this.jScopAdditionalPanel.setVisible(false);

	    //org.jdesktop.layout.GroupLayout jScopPanelAdditionalLayout = new org.jdesktop.layout.GroupLayout(jScopAdditionalPanel);
	    //jScopAdditionalPanel.setLayout(jScopPanelAdditionalLayout);
	    //jScopPanelAdditionalLayout.setHorizontalGroup();
	    //jScopPanelAdditionalLayout.setVerticalGroup();
	}
	return this.jScopAdditionalPanel;
	
    }

private boolean isFloat(String str) {
    float tempFloat;
    try {
        tempFloat = Float.parseFloat(str);
        return true;
    } catch(NumberFormatException event) {
        return false;
    }
}

    private void jButtonAcceptActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonAcceptActionPerformed
    this.setVisible(false);
}//GEN-LAST:event_jButtonAcceptActionPerformed

private void jButtonResetActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonResetActionPerformed
    this.jListAttribute.clearSelection();
    this.jListRelation.clearSelection();
    this.expansionRelationTypesSet.clear();
    this.expansionAttributesMap.clear();
    while(true){
        try{
            ((DefaultTableModel)this.jTableAttribute.getModel()).removeRow(0);
        } catch( Exception exc ){
            break;
        }
    }
}//GEN-LAST:event_jButtonResetActionPerformed

private void jButtonCancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonCancelActionPerformed
    this.jListAttribute.clearSelection();
    this.jListRelation.clearSelection();
    this.expansionRelationTypesSet.clear();
    this.expansionAttributesMap.clear();
    while(true){
        try{
            ((DefaultTableModel)this.jTableAttribute.getModel()).removeRow(0);
        } catch( Exception exc ){
            break;
        }
    }
    this.setVisible(false);
}//GEN-LAST:event_jButtonCancelActionPerformed

private void jListRelationValueChanged(javax.swing.event.ListSelectionEvent evt) {//GEN-FIRST:event_jListRelationValueChanged
    this.expansionRelationTypesSet.clear();
    this.expansionRelationTypesSet.addAll((java.util.Collection) java.util.Arrays.asList(this.jListRelation.getSelectedValues()));
}//GEN-LAST:event_jListRelationValueChanged

private void jListAttributeValueChanged(javax.swing.event.ListSelectionEvent evt) {//GEN-FIRST:event_jListAttributeValueChanged
    if(jListAttribute.getModel().getElementAt(jListAttribute.getLeadSelectionIndex()).equals("proteinsequence")) {
	this.getJScopAdditionalPanel().setVisible(false);
	jPanelAdditional.setVisible(true);
        jLabel3.setVisible(true);
        if (this.initialSize == null)
            this.initialSize = this.getSize();
        this.setSize(466, 457);
    }
    else if( jListAttribute.getModel().getElementAt(jListAttribute.getLeadSelectionIndex()).equals("scop")){
	jLabel3.setVisible(true);
	jPanelAdditional.setVisible(false);
	this.getJScopAdditionalPanel().setVisible(true);
	if (this.initialSize == null)
            this.initialSize = this.getSize();
        this.setSize(466, 457);
    }
    else {
        jPanelAdditional.setVisible(false);
        jLabel3.setVisible(false);
	this.getJScopAdditionalPanel().setVisible(false);
        if (this.initialSize != null && this.initialSize != this.getSize()) {
            this.setSize(this.initialSize);
        }
    }   
}//GEN-LAST:event_jListAttributeValueChanged

    /**
    * @param args the command line arguments
    */
    
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                AttributeExpansionDialog2 dialog = new AttributeExpansionDialog2(new javax.swing.JFrame(), null, null, null);
                dialog.addWindowListener(new java.awt.event.WindowAdapter() {
                    public void windowClosing(java.awt.event.WindowEvent e) {
                        System.exit(0);
                    }
                });
                dialog.setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jButtonAccept;
    private javax.swing.JButton jButtonAttribute;
    private javax.swing.JButton jButtonCancel;
    private javax.swing.JButton jButtonReset;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JList jListAttribute;
    private javax.swing.JList jListRelation;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanelAdditional;
    private javax.swing.JPanel jScopAdditionalPanel = null;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JScrollPane jScrollPane3;
    private javax.swing.JTable jTableAttribute;
    private javax.swing.JTextField jTextFieldBitScore;
    private javax.swing.JTextField jTextFieldCoverageMatch;
    private javax.swing.JTextField jTextFieldCoverageQuery;
    private javax.swing.JTextField jTextFieldIdentity;
    private javax.swing.JTextField jTextFieldSimilarity;
    // End of variables declaration//GEN-END:variables

}
